/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package datos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Ing. Monica Merlo, Ing. Agustin  Fernandez
 */
@Entity
@Table(name = "domicilio")
@NamedQueries({@NamedQuery(name = "Domicilio.findAll", query = "SELECT d FROM Domicilio d"),
@NamedQuery(name = "Domicilio.findById", query = "SELECT d FROM Domicilio d WHERE d.id = :id"),
@NamedQuery(name = "Domicilio.findByNumero", query = "SELECT d FROM Domicilio d WHERE d.numero = :numero"),
@NamedQuery(name = "Domicilio.findByPiso", query = "SELECT d FROM Domicilio d WHERE d.piso = :piso"),
@NamedQuery(name = "Domicilio.findByDepto", query = "SELECT d FROM Domicilio d WHERE d.depto = :depto"),
@NamedQuery(name = "Domicilio.findByCodPostal", query = "SELECT d FROM Domicilio d WHERE d.codPostal = :codPostal")})
public class Domicilio implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Lob
    @Column(name = "calle")
    private String calle;
    @Basic(optional = false)
    @Column(name = "numero")
    private String numero;
    @Basic(optional = false)
    @Lob
    @Column(name = "barrio")
    private String barrio;
    @Column(name = "piso")
    private Integer piso;
    @Column(name = "depto")
    private String depto;
    @Basic(optional = false)
    @Column(name = "codPostal")
    private String codPostal;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDomicilio")
    private Collection<Usuario> usuarioCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDomicilio")
    private Collection<ResponsableObra> responsableObraCollection;
    @JoinColumn(name = "idLocalidad", referencedColumnName = "id")
    @ManyToOne
    private Localidad idLocalidad;
    @JoinColumn(name = "idPais", referencedColumnName = "id")
    @ManyToOne
    private Pais idPais;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDomicilio")
    private Collection<EmpresaContratista> empresaContratistaCollection;

    public Domicilio() {
    }

    public Domicilio(Integer id) {
        this.id = id;
    }

    public Domicilio(Integer id, String calle, String numero, String barrio, String codPostal) {
        this.id = id;
        this.calle = calle;
        this.numero = numero;
        this.barrio = barrio;
        this.codPostal = codPostal;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCalle() {
        return calle;
    }

    public void setCalle(String calle) {
        this.calle = calle;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public String getBarrio() {
        return barrio;
    }

    public void setBarrio(String barrio) {
        this.barrio = barrio;
    }

    public Integer getPiso() {
        return piso;
    }

    public void setPiso(Integer piso) {
        this.piso = piso;
    }

    public String getDepto() {
        return depto;
    }

    public void setDepto(String depto) {
        this.depto = depto;
    }

    public String getCodPostal() {
        return codPostal;
    }

    public void setCodPostal(String codPostal) {
        this.codPostal = codPostal;
    }

    public Collection<Usuario> getUsuarioCollection() {
        return usuarioCollection;
    }

    public void setUsuarioCollection(Collection<Usuario> usuarioCollection) {
        this.usuarioCollection = usuarioCollection;
    }

    public Collection<ResponsableObra> getResponsableObraCollection() {
        return responsableObraCollection;
    }

    public void setResponsableObraCollection(Collection<ResponsableObra> responsableObraCollection) {
        this.responsableObraCollection = responsableObraCollection;
    }

    public Localidad getIdLocalidad() {
        return idLocalidad;
    }

    public void setIdLocalidad(Localidad idLocalidad) {
        this.idLocalidad = idLocalidad;
    }

    public Pais getIdPais() {
        return idPais;
    }

    public void setIdPais(Pais idPais) {
        this.idPais = idPais;
    }

    public Collection<EmpresaContratista> getEmpresaContratistaCollection() {
        return empresaContratistaCollection;
    }

    public void setEmpresaContratistaCollection(Collection<EmpresaContratista> empresaContratistaCollection) {
        this.empresaContratistaCollection = empresaContratistaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Domicilio)) {
            return false;
        }
        Domicilio other = (Domicilio) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "datos.Domicilio[id=" + id + "]";
    }

}
